//
//  File.swift
//  
//
//  Created by S JZ on 2024/8/20.
//

import Foundation

extension BasicWrapper where Base == Int {
    public var fit: Int { return self.base * Int(Define.shared.fit) }
}

extension BasicWrapper where Base == Float {
    public var fit: Float { return self.base * Float(Define.shared.fit) }
}

extension BasicWrapper where Base == Double {
    public var fit: Double { return self.base * Double(Define.shared.fit) }
}

extension BasicWrapper where Base == CGFloat {
    public var fit: CGFloat { return self.base * Define.shared.fit }
}

extension BasicWrapper where Base == CGSize {
    public var fit: CGSize {
        var width = self.base.width * Define.shared.fit
        var height = self.base.height * Define.shared.fit
        
#if os(iOS)
        if self.base.width == Define.shared.ScreenWidth { width = self.base.width }
        if self.base.height == Define.shared.ScreenHeight { height = self.base.height }
#endif
        return CGSize(width: width, height: height)
    }
}

extension BasicWrapper where Base == CGRect {
    public var fit: CGRect {
        let x = self.base.origin.x * Define.shared.fit
        let y = self.base.origin.y * Define.shared.fit
        
        var width = self.base.size.width * Define.shared.fit
        var height = self.base.size.height * Define.shared.fit
        
#if os(iOS)
        if self.base.size.width == Define.shared.ScreenWidth { width = self.base.size.width }
        if self.base.size.height == Define.shared.ScreenHeight { height = self.base.size.height }
#endif
        return CGRect(x: x, y: y, width: width, height: height)
    }
}
